
public class Motor
{
	String motorName = "";
	int encoderVal = 0;
	
	public Motor(String name)
	{
		motorName = name;
		encoderVal = 0;
		System.out.println("Registered motor: " + motorName);
	}
	
	int GetEncoderVal()
	{
		return encoderVal;
	}
	
	void SimulateEncoderChange(int change)
	{
		encoderVal += change;
	}
	
	void SimulateDrive(int targetDistance)
	{
		//Run forwards
		while(encoderVal < targetDistance)
		{	
			SimulateEncoderChange(1);
			System.out.println("Distance traveled: " + GetEncoderVal());
			
			//Simulate time
			try
			{
				Thread.sleep(200);
			}
			catch (InterruptedException e)
			{
				e.printStackTrace();
			}
		}
		
		//Run backwards
		while(encoderVal > targetDistance)
		{
			SimulateEncoderChange(-1);
			System.out.println("Distance traveled: " + GetEncoderVal());

			//Simulate time
			try
			{
				Thread.sleep(200);
			}
			catch (InterruptedException e)
			{
				e.printStackTrace();
			}
		}
		//StopMotor();
	}
}
